<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>关闭弹窗</title>
	</head>
	<body>
		<button>打开一个弹窗，3s后自动关闭</button>

		<script>
			const windowOpen = document.querySelector('button')

			windowOpen.addEventListener('click', (e) => {
				// const newWin = window.open('about:blank', 'hello', 'width=200,height=200')
				const newWin = window.open('https://www.baidu.com/', 'hello', 'width=200,height=200')

				newWin.document.write('hi ✿(。◕‿◕。)✿ ~')

				// newWin.onload = function () {
				setTimeout(() => {
					newWin.close()
					alert('弹窗状态：' + (newWin.closed ? '已关闭' : '未关闭'))
				}, 1000)
				// }
			})
		</script>
	</body>
</html>
